﻿using IntelligentAgriculture.Contracts.Dto.Output.DeathModelsOutPut;
using IntelligentAgriculture.Contracts.Interface.EliminationModelService;
using IntelligentAgriculture.Domain.Entity;
using IntelligentAgriculture.WebAPI.Application.Command.DeathModelCommand;
using IntelligentAgriculture.WebAPI.Application.Command.EliminationModelCommand;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.EliminationModelCommandHandler
{
    public class EliminationFindCommandHandler : IRequestHandler<EliminationFindCommand, Results<Eliminationmodel>>
    {
        private readonly IEliminationModelService _IeliminationModelService;
        public EliminationFindCommandHandler(IEliminationModelService ieliminationModelService)
        {
            _IeliminationModelService = ieliminationModelService;
        }
        /// <summary>
        /// 淘汰列表反填功能
        /// </summary>
        /// <param name="request">反填淘汰信息的命令请求对象</param>
        /// <param name="cancellationToken">取消操作的取消标记</param>
        /// <returns>表示异步操作的任务，返回结果为包含淘汰信息模型列表的结果对象</returns>

        public async Task<Results<Eliminationmodel>> Handle(EliminationFindCommand request, CancellationToken cancellationToken)
        {
            try
            {
                var list = await _IeliminationModelService.Find(request.id);
                return Results<Eliminationmodel>.DataResult(list);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
